package com.EAIPClub.CodeShellManager.mapper;

import com.api.POJO.CodeLab.CodeShellManager.CodeShellManagerContentInfo;
import com.api.POJO.CodeLab.CodeShellManager.CodeShellManagerHost;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description :
 * @Author :
 * @Date : 2021/12/6
 */
@Mapper
@Repository
public interface CodeShellManagerHostListMapper {
    @Select("SELECT * FROM t_hostlist WHERE 1=1")
    List<CodeShellManagerHost> getAllCodeShellHosts();

    @Select("SELECT * FROM t_hostlist WHERE ready='Y'")
    List<CodeShellManagerHost> getAllCodeShellFreeHosts();

    @Select("SELECT * FROM t_hostlist WHERE session=''")
    List<CodeShellManagerHost> getAllCodeShellNonSessionHosts();

    @Select("SELECT * FROM t_hostlist WHERE useruid = '${useruid}'")
    CodeShellManagerHost getCodeShellByUserUid(@Param("useruid")String useruid);

    @Update("UPDATE t_hostlist SET ready = '${status}' WHERE ID = ${id}")
    Boolean updateCodeIdeHostStatusById(@Param("status") Character status, @Param("id") Integer id);

    @Update("UPDATE t_hostlist SET ready = '${status}' WHERE name = '${name}'")
    Boolean updateCodeIdeHostStatusByName(@Param("status") Character status, @Param("name") String name);

    @Update("UPDATE t_hostlist SET ready = '${status}' WHERE session = '${session}'")
    Boolean updateCodeIdeHostStatusBySession(@Param("status") Character status, @Param("session") String session);

    @Update("UPDATE t_hostlist SET useruid = '${useruid}' WHERE ID = ${id}")
    Boolean updateCodeIdeHostUserUidById(@Param("useruid") String useruid, @Param("id") Integer id);

    @Update("UPDATE t_hostlist SET useruid = '${useruid}' WHERE session = '${session}'")
    Boolean updateCodeIdeHostUidBySession(@Param("useruid") String uid, @Param("session") String session);

    @Update("UPDATE t_hostlist SET useruid = '${useruid}' WHERE name = '${name}'")
    Boolean updateCodeIdeHostUserUidByName(@Param("useruid") String useruid, @Param("name") String name);

    @Update("UPDATE t_hostlist SET session = '${session}' WHERE ID = ${id}")
    Boolean updateCodeIdeHostSessionById(@Param("session") String session, @Param("id") Integer id);

    @Update("UPDATE t_hostlist SET session = '${Nsession}' WHERE session = '${Osession}'")
    Boolean updateCodeIdeHostSessionBySession(@Param("Nsession") String Nsession, @Param("Osession") String Osession);


}
